{% extends "base.html" %}
{% load i18n plmapp_tags %}
{% block css %}
<link type="text/css" href="{{STATIC_URL}}css/files.css" rel="Stylesheet" />
{% endblock %}


{% block content %}
    {% if is_contributor and obj.is_editable and not last_revision.deprecated %}
        <div id="add_file_container" class="ci hidden">
            {% include "documents/files_add.html" %}
        </div>
    {% endif %}
    <div>
        <h3 class="hplm"> {{ last_revision.filename }} </h3>
        <div>
            <div style="display:inline-block" class="file">
                <p>
                {% if last_revision.thumbnail %}
                <img class="thumbnail" src="{{last_revision.thumbnail.url}}" align="left"/>
            {% endif %}
                {% if last_revision.deleted %}
                    <p>{% trans "Deleted." %}
                {% else %}
                    <a class="tb-btn" href="/file/{{last_revision.id}}/{{last_revision.filename|urlencode}}">
                        <span class="ui-button-text">{% trans "DOWNLOAD" %}</span>
                    </a>
                {% endif %}
                {% if last_revision.deprecated %}
                    {% trans "Deprecated." %}
                 {% else %}
                     {% include "documents/checkout_btn.html" with doc_file=last_revision %}
           
                {% endif %}
                </p>
            </div>

            <div>
                <table class="Content">
                    <tr class="Content">
                        <td class="Content description">{% trans "Filename" %}</td>
                        <td class="Content">{{ last_revision.filename }}</td>
                    </tr>
                    <tr class="Content">
                        <td class="Content description">{% trans "Revision" %}</td>
                        <td class="Content">{{ last_revision.revision }}</td>
                    </tr>
                    <tr class="Content">
                        <td class="Content description">{% trans "Size" %}</td>
                        <td class="Content">{{ last_revision.size|filesizeformat }}</td>
                    </tr>
                    <tr class="Content">
                        <td class="Content description">{% trans "Date of creation" %}</td>
                        <td class="Content">
                            {{ last_revision.ctime|date:"DATETIME_FORMAT" }} — 
                            {% blocktrans with last_revision.ctime|timesince as time_since %}{{time_since}} ago{% endblocktrans %}
                        </td>
                    </tr>

                </table>
            </div>
        </div>
    </div>

    <div>
        <h3 class="hplm"> {% blocktrans with last_revision.filename as filename %}Previous revisions of {{ filename}}{%endblocktrans %} </h3>

        <div>
            {% if doc_files %}
            <table class="Content">
                <thead>
                    <th>{% trans "Revision" %}</th>
                    <th>{% trans "Size" %}</th>
                    <th>{% trans "Download" %}</th>
                    <th>{% trans "Thumbnail" %}</th>
                    <th>{% trans "Date of creation" %}</th>
                </thead>
                <tbody>
                {% for doc_file in doc_files %}

                    <tr class="Content">
                        <td>
                            <span>{{ doc_file.revision }}</span>
                        </td>

                        <td class="Content">{{doc_file.size|filesizeformat}}</td>
                        <td class="Content">
                            {% if doc_file.deleted %}
                                <span>{% trans  "File deleted"%} </span>
                            {% else %}
                                <a class="tb-btn" href="/file/{{doc_file.id}}/{{doc_file.filename|urlencode}}">
                                    <span class="ui-button-text">{% trans "DOWNLOAD" %}</span>
                                </a>
                            {% endif %}
                        </td>
                        <td class="Content">
                            {% if doc_file.thumbnail %}
                                <img class="thumbnail" src="{{doc_file.thumbnail.url}}"
                                alt="Thumbnail"/>
                            {% else %}
                                {% trans "No thumbnail available" %}
                            {% endif %}
                        </td>
                        <td class="Content">
                            {{ doc_file.ctime|date:"DATETIME_FORMAT" }} — 
                            {% blocktrans with doc_file.ctime|timesince as time_since %}{{time_since}} ago{% endblocktrans %}
                        </td>
                    </tr>
                {% endfor %}	    
            </tbody>
            </table>
        {% else %}
            <p>{% trans "No previous revisions." %}</p>
        {% endif %}
        </div>
    </div>
   <div id="dialog_check-out" class="hidden" title="{% trans "Confirm CHECK-OUT" %}">
        {% trans "You'are checking out a standardfile while a native file is available. Your native file will be deprecated and will not be usable anymore." %}
    </div>
{% endblock %}


